package ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-24
 * Time: 17:07
 */
public class FindOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println();
        System.out.println("=====查找图书=====");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您要查找图书的书名：");
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)) {
                System.out.println("成功查找到该图书！！！");
                System.out.println(book);
                System.out.println();
                return;
                }
            }
        System.out.println("没有查找到该图书！！！");
        System.out.println();
    }
}
